|
|
|
|
|
|
|
Figure 19.9.
Adding the frmSQLData utility form to the project. |
|
|
|
|
|
|
|
|
Next, you need to code the ExecDirect method. This is the wrapper method for the SQLDirectExec API call. Add the code in Listing 19.12 to the class module. |
|
|
|
|
|
|
|
|
Listing 19.12. Coding the ExecDirect method. |
|
|
|
|
|
|
|
|
Public Function ExecDirect()
'
' perform an SQL statement
'
Dim intResult As Integer
'
' clear any in-process stuff
If hStmt <> 0 Then
intResult = SQLFreeStmt(hStmt, sqlClose)
intResult = SQLFreeStmt(hStmt, sqlUnbind)
intResult = SQLFreeStmt(hStmt, sqlResetParams)
End If
'
If intResult <> sqlSuccess Then
ExecDirect = intResult
Err.Raise vbObjectError + 11, App.EXEName, "Error freeing old statement
handle"
intResult = SQLFreeStmt(hStmt, sqlClose)
Exit Function
End If
'
' Do the query & wait
intResult = SQLExecDirect(hStmt, SQL, Len(SQL))
Do While intResult = sqlStillExecuting
intResult = SQLExecDirect(hStmt, SQL, Len(SQL))
DoEvents
Loop
'
' check for errors
If intResult <> sqlSuccess Then |
|
|
|
|
|